//----------------------------------*-C++-*----------------------------------//
/*!
 * \file   State.cc
 * \author Jeremy Roberts
 * \date   Aug 31, 2011
 * \brief  State member definitions and explicit instantiations.
 * \note   Copyright (C) 2011 Jeremy Roberts. 
 */
//---------------------------------------------------------------------------//
// $Rev:: 141                                           $:Rev of last commit
// $Author:: j.alyn.roberts@gmail.com                   $:Author of last commit
// $Date:: 2011-09-14 19:28:23 +0000 (Wed, 14 Sep 2011) $:Date of last commit
//---------------------------------------------------------------------------//

#include "tran/State.hh"

namespace slabtran
{

// Constructor.
template <class Equations, class D>
State<Equations, D>::State(SP_input input, SP_mesh mesh,
                           SP_angularmesh angularmesh)
  : d_input(input),
    d_mesh(mesh),
    d_angularmesh(angularmesh),
    d_number_groups(input->number_groups()),
    d_scalar_flux(d_number_groups),
    d_angular_flux(d_number_groups),
    d_keff(-1.0),
    d_moments_size(0.0),
    d_psi_size(0.0)
{
  Require(d_mesh);
  Require(d_angularmesh);
  Require(d_number_groups > 0);
  Require(d_scalar_flux.size() == d_number_groups);
  Require(d_angular_flux.size() == d_number_groups);

  // Determine moments size.
  int number_moments = Moments<D>::number_moments(d_input->legendre_order());
  int number_cells = d_mesh->number_cells();
  int number_unknowns = Equations::number_unknowns();
  d_moments_size = number_cells * number_unknowns * number_moments;

  // Allocate the group moments.
  for (int g = 0; g < d_number_groups; g++)
    d_scalar_flux[g] = new Moments_Field_t(mesh, d_input->legendre_order());

  if (d_input->store_psi())
  {
    // Determine psi size.
    int number_angles = d_angularmesh->number_angles();
    d_psi_size = number_cells * number_unknowns * number_angles;

    // Allocate the group angular fluxes.
    for (int g = 0; g < d_number_groups; g++)
      d_angular_flux[g] = new Psi_Cell_Field_t(mesh, number_angles);
  }

}

// Instantiations.
template class State<DD_1D_Equations,_1D>;
template class State<DD_2D_Equations,_2D>;
template class State<DD_3D_Equations,_3D>;


} // end namespace slabtran

//---------------------------------------------------------------------------//
//              end of State.cc
//---------------------------------------------------------------------------//
